﻿using Abp.Application.Services.Dto;
using Abp.Timing;
using System;

namespace ARchGL.Platform.Dtos
{
    /// <summary>
    /// 文件库信息 ViewModel
    /// </summary>
    public class DocumentLibrarysDto : EntityDto<Guid>
    {
        /// <summary>
        /// 主键标识（项目/人员等等）
        /// </summary>
        public Guid? PrimaryId { get; set; }
        /// <summary>
        /// 《检验批》验收节点标识
        /// </summary>
        public Guid PrimaryId1 { get; set; }
        ///// <summary>
        ///// 场景标识
        ///// </summary>
        //public Guid PrimaryId2 { get; set; }
        /// <summary>
        /// 上级分类
        /// </summary>
        public Guid? ParentId { get; set; }
        /// <summary>
        /// 文件/文件夹 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 大小（存储单位为 B）
        /// </summary>
        public int Size { get; set; }
        /// <summary>
        /// 文件标识来自文件系统，如果没有则是文件夹
        /// </summary>
        public Guid? FileId { get; set; }
        /// <summary>
        /// 链接地址
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 扩展名
        /// </summary>
        public string Extension { get; set; }
        /// <summary>
        /// 创建人标识
        /// </summary>
        public Guid? CreatorUserId { get; set; }
        /// <summary>
        /// 创建人名称
        /// </summary>
        public string CreatorUserName { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreationTime { get; set; }
        /// <summary>
        /// 创建时间戳
        /// </summary>
        public long CreationUniversalTime { get { return CreationTime.ToUnixTimestamp(); } }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 更新时间时间戳
        /// </summary>
        public long LastModificationUniversalTime
        {
            get
            {
                return LastModificationTime.HasValue
                    ? LastModificationTime.Value.ToUnixTimestamp()
                    : DateTime.MinValue.ToUnixTimestamp();
            }
        }
        /// <summary>
        /// 类型：1文件夹、2文件
        /// </summary>
        public int Type { get { return FileId.HasValue ? 2 : 1; } }


        /// <summary>
        /// 类型
        /// </summary>
        public EnumDocumentPType PType { get; set; }


        /// <summary>
        /// 文件Hash
        /// </summary>
        public string Hash { get; set; }

        /// <summary>
        /// 文件Path
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 文件上传成功后返回数据
        /// </summary>
        public string FileResponse { get; set; }

        /// <summary>
        /// 是否同步 false/true
        /// </summary>
        public bool State { get; set; }

        /// <summary>
        /// 是否系统级
        /// </summary>
        public bool IsSystem { get; set; }


        /// <summary>
        /// 透传字段
        /// </summary>
        public string TransInfo { get; set; }

        ///// <summary>
        ///// 文件状态
        ///// 0 已上传
        ///// 1 正在转换
        ///// 2 转换成功
        ///// </summary>
        //private EnumFileState FileState { get; set; }
    }

    /// <summary>
    /// 检验批相关
    /// </summary>
    public class DocumentLibrarysDtoForCheckP : DocumentLibrarysDto
    {
        /// <summary>
        /// 绑定构件标识
        /// </summary>
        public string[] PropertyIds { get; set; }

        /// <summary>
        /// 模板标识
        /// </summary>
        public Guid TemplateId { get; set; }
    }
}
